#ifndef NBODYHOLDER_H
#define NBODYHOLDER_H

// This class holds the information about the masses in the simulation.
// This class provides access to each body and computes the
// accelleration.

// All details about how the masses are stored or how the acceleration
// is calculated are abstracted in the private functions.

// Masses may be accessed using brackets, and this class can be used
// like a vector. This does not necessarily mean this is how the masses
// are actually being stored.

#include "Body.h"
#include "macros.h"
#include "ParamHolder.h"

#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

class nBodyHolder
{
   public:
      nBodyHolder();
      nBodyHolder(string fn, ParamHolder*);

      void readFromFile(string);
      void writeToFile(string);

      void addBody(Body*);
      Body* getBody(int);

      int size();
      void centerSystem();

      vec accel(int);

   private:
      // No reason this couldn't be a struct.
      class BodyNode
      {
         public:
            Body* b;
	    BodyNode* next;
      };

      BodyNode* head;
      ParamHolder* params;

      int nBodies;

      string prepLine(string);

      double getNum(string s);
      string rmFirstNum(string s);
};

#endif //NBODYHOLDER_H
